from typing import *


class Solution:
    def removeAlmostEqualCharacters(self, word: str) -> int:
        ans, c = 0, False

        def f(i):
            return abs(ord(word[i]) - ord(word[i - 1])) < 2

        for i in range(1, len(word)):
            if not c:
                if f(i):
                    c = True
                    ans += 1
            else:
                c = False
        return ans
